package org.pupil.tolerant;

import org.pupil.common.URL;
import org.pupil.socket.codec.RpcProtocol;
import org.pupil.socket.codec.RpcRequest;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @Description: 故障上下文
 * @Author: pupil
 * @Date: 2024/07/17 下午 3:49
 */
public class FaultContext {

    private URL currentURL; // 当前服务提供方的资源定位符

    private List<URL> urls; // 服务提供方的资源定位符集合

    private  RpcProtocol<RpcRequest> rpcProtocol; // 请求消息协议

    private Long requestId; // 请求id

    private long time; // 异常等待超时时间

    private TimeUnit timeUnit; // 异步等待时间单位

    private Exception exception; // 错误

    public FaultContext() {
    }

    public FaultContext(URL currentURL, List<URL> urls, RpcProtocol<RpcRequest> rpcProtocol, Long requestId, long time, TimeUnit timeUnit, Exception exception) {
        this.currentURL = currentURL;
        this.urls = urls;
        this.rpcProtocol = rpcProtocol;
        this.requestId = requestId;
        this.time = time;
        this.timeUnit = timeUnit;
        this.exception = exception;
    }

    public URL getCurrentURL() {
        return currentURL;
    }

    public void setCurrentURL(URL currentURL) {
        this.currentURL = currentURL;
    }

    public List<URL> getUrls() {
        return urls;
    }

    public void setUrls(List<URL> urls) {
        this.urls = urls;
    }

    public RpcProtocol<RpcRequest> getRpcProtocol() {
        return rpcProtocol;
    }

    public void setRpcProtocol(RpcProtocol<RpcRequest> rpcProtocol) {
        this.rpcProtocol = rpcProtocol;
    }

    public Long getRequestId() {
        return requestId;
    }

    public void setRequestId(Long requestId) {
        this.requestId = requestId;
    }

    public Exception getException() {
        return exception;
    }

    public void setException(Exception exception) {
        this.exception = exception;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public TimeUnit getTimeUnit() {
        return timeUnit;
    }
}
